EnemyFactory = {}

local this = EnemyFactory

local transform
local gameObject
local point
local BossPoint
local boss

function EnemyFactory.New()
    UpdateBeat:Add(this.Update)    
end

local _time = 0
local boss_time= 0
function EnemyFactory.Update( )
    if (Time.time - _time > 2) then
        _time = Time.time

        this.Creat()
    end
    if (Time.time - boss_time > 15) then
        boss_time = Time.time

        this.CreatBoss()
    end
end

function EnemyFactory.Creat()
    local num = math.random(3,7)--随机生成敌人个数
    local enemyIndex = math.random(4,6)--敌人类型索引
    for i = 1,num do
        gameObject = newObject(ThunderManager.prefabs[enemyIndex])
        transform = gameObject.transform
        gameObject.tag ="Enemy"

        point = newObject(ThunderManager.prefabs[7]).transform

        local pos = math.random(0,30)
        local wavepos = point:GetChild(pos)

        transform.position = wavepos.position
        transform.rotation = wavepos.rotation
        this.Enemy()
    end
end

function EnemyFactory.Enemy()
    local enemy = Enemy.new(gameObject)
end


function EnemyFactory.CreatBoss()
    boss = newObject(ThunderManager.prefabs[8])
    boss.tag = "Boss"

    BossPoint = newObject(ThunderManager.prefabs[9]).transform
    boss.transform.position = BossPoint.position
    this.Boss()
end

function EnemyFactory.Boss()
    local Boss = BossAI.new(boss)
end